package cn.zhibang.yygh.common.util;

import cn.zhibang.yygh.common.util.JwtHelper;

import javax.servlet.http.HttpServletRequest;

//获取当前用户信息工具类
public class AuthContextHolder2 {
    //1.获取当前用户id
    public static Long getUserId(HttpServletRequest request) {
        //1.1从header获取token
        String token = request.getHeader("token");
        //1.2jwt从token获取userid
        Long userId = JwtHelper.getUserId(token);
        return userId;
    }

    //2.获取当前用户名称
    public static String getUserName(HttpServletRequest request) {
        //1.1从header获取token
        String token = request.getHeader("token");
        //1.2jwt从token获取userid
        String userName = JwtHelper.getUserName(token);
        return userName;
    }
}